package com.circuit.circuit;

import java.applet.Applet;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

public class Circuit extends Applet {
    static CirSim ogf;
    boolean finished = false;
    boolean started = false;

    public static void main(String args[]) {
        ogf = new CirSim(null);
        ogf.init();
    }

    @Override
    public void init() {
        addComponentListener(new ComponentAdapter() {
            @Override
            public void componentShown(ComponentEvent e) {
                showFrame();
            }

            @Override
            public void componentResized(ComponentEvent e) {
                if (ogf != null) {
                    ogf.componentResized(e);
                }
            }
        });
    }

    public void showFrame() {
        if (finished) {
            repaint();
            return;
        }
        if (ogf == null) {
            started = true;
            ogf = new CirSim(this);
            ogf.init();
        }
        ogf.setVisible(true);
        repaint();
    }

    public void hideFrame() {
        if (finished) {
            return;
        }
        ogf.setVisible(false);
        repaint();
    }

};
